﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TtfLibrary
{
    public class OttLoca: IAfterWrite
    {
        [TtfStop]
        public List<UInt32> Offsets = new List<UInt32>();

        public bool IsLong;

        public void Read(TtfStructureReader reader, int count, bool isLong)
        {
            IsLong = isLong;
            for(int i = 0; i < count; i++)
                Offsets.Add(isLong ? reader.Read<UInt32>() : reader.Read<UInt16>());
        }

        public void AfterWrite(StructureWriter writer)
        {
            foreach (var item in Offsets)
                if (IsLong)
                    writer.WriteScalarType((UInt32)item);
                else
                    writer.WriteScalarType((UInt16)item);
        }
    }
}
